#!/usr/bin/env python
#coding=utf-8
import threading
import time
import os

import wx

class TimerThread(threading.Thread):
    
    def __init__(self, window, time, index):
        '''${3:}'''
        threading.Thread.__init__(self)
        self.window = window
        self.index = index
        self.toStop = False
        self.int_time = [int(i) for i in time.split()]
    
    def run(self):
        '''${3:}'''
        while time.localtime()[3:6] < tuple( [ int(i) for i in self.int_time ] ):            
            if self.toStop == True:
                return
            print time.localtime()[3:6]
            time.sleep(1)
        os.popen2('beep -r30')
        wx.CallAfter(self.window.ShowMessage, self.index)
        wx.CallAfter(self.window.UpdateStatus, self.index)
        return
        
    def stop(self):
        '''${3:}'''
        self.toStop = True